import React, { Component } from 'react'
import PropTypes from 'prop-types'
import HighComponent from './Hoc'
import getDefaultOption from '../GenOptions'

class ExtremeTempYear extends Component {
  componentDidMount() {
    this.update()
  }
  componentDidUpdate() {
    // this.update()
  }
  update = () => {
    const { echart } = this.props
    const { result: { dates, minExtremeTemperature, maxExtremeTemperature } } = this.props
    echart.setOption(
      getDefaultOption('极端温度按年统计(天)', 
        ['最高温>90°F', '最低温>70°F'],
        dates,
        [
          {
            name: '最低温>70°F',
            type: 'line',
            itemStyle: {
              normal: {
                lineStyle: {
                  width: 1
                }
              }
            },
            data: minExtremeTemperature

          },
          {
            name: '最高温>90°F',
            type: 'line',
            itemStyle: {
              normal: {
                lineStyle: {
                  width: 1
                }
              }
            },
            data: maxExtremeTemperature
          },
        ],
        function (value) {
          return value
        } 
      ))
  }
 
 
  render() {
    return (
      null
    )
  }
}

ExtremeTempYear.propTypes = {
  result: PropTypes.object,
  echart: PropTypes.object,
  unit: PropTypes.bool,
}

export default HighComponent(ExtremeTempYear, 'extreme_temperature_year')